package com.yunfeisoft.business.dao.impl;

import com.yunfeisoft.business.dao.inter.RoomDao;
import com.yunfeisoft.business.model.Room;
import com.yunfeisoft.common.base.BaseDaoImpl;
import com.yunfeisoft.common.sql.builder.WhereBuilder;
import com.yunfeisoft.common.utils.Page;
import org.springframework.stereotype.Repository;
import org.springframework.util.ObjectUtils;

import java.util.List;
import java.util.Map;

/**
 * ClassName: RoomDaoImpl
 * Description: 房间Dao实现
 * Author: Jackie liu
 * Date: 2020-01-13
 */
@Repository
public class RoomDaoImpl extends BaseDaoImpl<Room, String> implements RoomDao {

    @Override
    public Page<Room> queryPage(Map<String, Object> params) {
        WhereBuilder wb = new WhereBuilder();
        if (params != null) {
            initPageParam(wb, params);
            wb.andEquals("floorNum", params.get("floorNum"));
            wb.andEquals("type", params.get("type"));
            wb.andFullLike("roomNum", params.get("roomNum"));
        }
        return queryPage(wb);
    }

    @Override
    public List<Room> queryListCondition(Map<String, Object> params) {
        WhereBuilder wb = new WhereBuilder();
        if (params != null) {
            initPageParam(wb, params);
            if (!ObjectUtils.isEmpty(params.get("floorNum"))) {
                wb.andEquals("floorNum", params.get("floorNum"));
            }
        }
        return query(wb);
    }

    @Override
    public List<Room> listAll(Map<String, Object> params) {
        WhereBuilder wb = new WhereBuilder();
        return query(wb);
    }
}